package java44th.group.controller.wx.search;

import java44th.group.bean.admin.vo.BaseRespVo;
import java44th.group.bean.wx.vo.search.SearchVo;
import java44th.group.service.wx.search.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Aurhor: 徐云飞
 * @DATE: 2022/10/14 23:08
 * @Description:
 * @Version 1.0
 */
@RestController
@RequestMapping("wx/search")
public class SearchController {
    @Autowired
    SearchService searchService;

    //搜索主页
    @GetMapping("index")
    public BaseRespVo index() {

        SearchVo searchVo = searchService.index();
        return BaseRespVo.ok(searchVo);


    }

    //搜索
    @GetMapping("helper")
    public BaseRespVo helper(String keyword) {

        List list = searchService.helper(keyword);
        return BaseRespVo.ok(list);

    }

    // 清空搜索记录
    @PostMapping("clearhistory")
    public BaseRespVo clearhistory() {

        searchService.clearhistory();


        return BaseRespVo.ok();
    }


}
